Table Functions
add
add(tbl,val,[index])
Add the element val at the index position in the table, if the index parameter is not filled in, it means appending to the end.
del
del(tbl,val)
Find and delete elements equal to val in the table (only delete the first one found).
deli
deli(tbl,[index])
Delete the element at the index position in the table, if the index parameter is not filled in, it means delete the last one.
count
count(tbl,[val])
Return the length of the table (#tbl), if val is provided, then returns the number of elements equal to val in the table.
all
all(tbl)
Return the iterative function of the table, used in the for loop to iterate the non-nil array data.
Example:
t={1,2,3}
for v in all(t) do
print(v)
end
foreach
foreach(tbl,fun)
Iterate over the array of tables, calling fun on each non-nil element.
Example:
foreach({1,2,3},print)